//
//  C_SongerListCollectionViewCell.m
//  音悦咖
//
//  Created by Best on 15/7/18.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "C_SongerListCollectionViewCell.h"

@implementation C_SongerListCollectionViewCell

- (void)dealloc
{
    [_imageView release];
    [_nameLabel release];
    [super dealloc];
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self create];
    }
    return self;
}

- (void)create
{
    self.clipsToBounds = YES;
    self.imageView = [[UIImageView alloc] init];
    self.imageView.clipsToBounds = YES;
    [self addSubview:self.imageView];
    [_imageView release];
    
    self.nameLabel = [[UILabel alloc] init];
    [self.nameLabel sizeToFit];
    self.nameLabel.textColor = [UIColor whiteColor];
    [self.imageView addSubview:self.nameLabel];
    self.nameLabel.font = [UIFont systemFontOfSize:15];
    [self.nameLabel setTextAlignment:(NSTextAlignmentCenter)];
    [_nameLabel release];
    
    
  
 
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    self.imageView.frame = layoutAttributes.bounds;
    
    self.nameLabel.frame = CGRectInset(self.imageView.frame, self.imageView.frame.size.width / 2 - 40, self.imageView.frame.size.height / 2 - 10);
    

}

- (void)setModel:(C_SongerListModel *)model
{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    [self.imageView setImageWithURL:model.pic_url placeholderImage:[UIImage imageWithContentsOfFile:GETBUNDLE_PATH(@"place", @"jpg")]];
    self.nameLabel.text = model.singer_name;
}

@end
